﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     BlackList业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class BlackListSqlMapDao : BaseSqlMapDao, IBlackListDao
    {
        private static BlackListSqlMapDao instance = null;
        private static object syncRoot = new object();

        private BlackListSqlMapDao()
        {
            //
            // TODO: 此处添加BlackListSqlMapDao的构造函数
            //
        }
        public static IBlackListDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new BlackListSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectBlackListByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<BlackList> GetList()
        {
            try
            {
                return ExecuteQueryForList<BlackList>("SelectBlackList", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<BlackList> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<BlackList>("SelectBlackListByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary> 
        /// 得到明细
        /// </summary>
        /// <param name="ListID"></param>
        /// <returns></returns>
        public BlackList GetDetail(BlackList bl)
        {
            try
            {
                return ExecuteQueryForObject<BlackList>("SelectBlackList", bl) as BlackList;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="blacklist"></param>
        /// <returns></returns>
        public object Add(BlackList blacklist)
        {
            //int id = GetId("BlackList");
            //blacklist.ListID = id;

            try
            {
                return ExecuteInsert("InsertBlackList", blacklist);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="blacklist"></param>
        /// <returns></returns>
        public int Update(BlackList blacklist)
        {
            try
            {
                return ExecuteUpdate("UpdateBlackList", blacklist);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ListID"></param>
        /// <returns></returns>
        public int Delete(System.String listid)
        {
            try
            {
                return ExecuteDelete("DeleteBlackList", listid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="blacklist"></param>
        /// <returns></returns>
        public int Delete(BlackList blacklist)
        {
            try
            {
                return ExecuteDelete("DeleteBlackList", blacklist.ListID);
            }
            catch
            {
                throw;
            }
        }
    }
}
